# 开发人员  ：  DanXinShang
# 开发时间  ：  2022/3/14  9:46 下午
# 文件名称  :  assemble.py
# 开发工具  :  PyCharm
import datetime
from utils.date_tools import timestamp_to_datetime

class Assemble(object):
    """
    组装数据
    """

    @classmethod
    def check_log(cls,
                  u_id,
                  user: dict,
                  timestamp: int,
                  device: str,
                  l_title="",
                  l_detail="",
                  group_name="",
                  checkin_type="WX",
                  ):
        """
        CheckLog 数据
        :param u_id:
        :param user: 当条数据为{'USER_CODE': , 'USER_NAME': }
        :param timestamp:
        :param device:设备
        :param l_title:
        :param l_detail:
        :param group_name:
        :param checkin_type:
        :return:
        """
        return {
            "check_id": u_id,
            "timestamp": timestamp,
            "user_code": user.get("user_code", ""),
            "user_name": user.get("user_name", ""),
            "check_in_time": timestamp_to_datetime(timestamp).replace(second=0),
            "device": device,
            "l_title": l_title,
            "l_detail": l_detail,
            "group_name": group_name,
            "checkin_type": checkin_type
        }

    @classmethod
    def date_record(cls, t_name, d_id, date):
        """
        DateRecord表
        :param t_name:
        :param d_id:
        :param date:
        :return:
        """
        return {
            "date_id": d_id,
            "table_flag": t_name,
            "date_flag": date
        }

    @classmethod
    def user_check(cls):
        return {
            "USER_CODE": "",
            "USER_NAME": "",
            "ZK_ID": "",
            "WX_ID": "",
            "DD_ID": "",
            "CHECK_FLAG": "",
            "LINE_FLAG": "",
            "IS_VALID": "",
        }

    @classmethod
    def query_user_check(cls, row):
        return [(row.ZK_ID, {
            "USER_CODE": row.USER_CODE,
            "USER_NAME": row.USER_NAME,
        }
                 )]


if "__main__" == __name__:
    print(Assemble.check_log(1, {}.get("0", None), 1381419635, ''))
    print(
        '''
    "user_code":"",
    "user_name":"",
    "zk_id":"",
    "wx_id":"",
    "dd_id":"",
    "check_flag":"",
    "line_flag":"",
    "is_valid":"",
        '''.upper()
    )
